import 'package:enterprise_v6_app/app/components/custom_app_bar.dart';
import 'package:enterprise_v6_app/app/components/process/approval_bottom_sheet.dart';
import 'package:enterprise_v6_app/app/components/process/approval_process_widget.dart';
import 'package:enterprise_v6_app/app/core/core.dart';
import 'package:enterprise_v6_app/app/modules/application/education/train_program/online_training/online_training_controller.dart';
import 'package:enterprise_v6_app/app/modules/application/education/train_program/online_training/plan_info/plan_info_view.dart';
import 'package:enterprise_v6_app/app/modules/application/education/train_program/online_training/train_course/train_course_view.dart';
import 'package:enterprise_v6_app/app/modules/application/education/train_program/online_training/train_result/train_result_view.dart';

///在线培训
class OnlineTrainingPage extends StatelessWidget {
  OnlineTrainingPage({super.key});

  final controller = Get.put(OnlineTrainingController());

  @override
  Widget build(BuildContext context) {
    return controller.isApprove
        ? Scaffold(
            appBar: CustomAppBar(
              titleText: '在线培训',
            ),
            body: Container(
              color: AppColors.bg_color_grey,
              child: DefaultTabController(
                length: 3,
                initialIndex: controller.initPage,
                child: Column(
                  children: [
                    Container(
                      decoration: BoxDecoration(
                        color: Colors.white,
                        borderRadius: BorderRadius.circular(8),
                      ),
                      height: 54.w,
                      child: TabBar(
                        enableFeedback: false,
                        tabs: const [
                          Tab(text: '计划信息'),
                          Tab(text: '培训课程'),
                          Tab(text: '审批流程'),
                        ],
                        tabAlignment: TabAlignment.center,
                        isScrollable: true,
                        dividerColor: Colors.transparent,
                        labelPadding: EdgeInsets.only(bottom: 10.w, left: 13.w, right: 13.w),
                        labelStyle: TextStyle(
                          fontSize: 16.sp,
                          fontWeight: FontWeight.w500,
                        ),
                        unselectedLabelStyle: TextStyle(
                          fontSize: 16.sp,
                          fontWeight: FontWeight.w500,
                        ),
                        labelColor: Colors.black,
                        unselectedLabelColor: const Color(0xffA0A7B5),
                        indicatorPadding: EdgeInsets.only(top: 36.w, bottom: 10.w),
                        indicator: const BoxDecoration(
                          image: DecorationImage(
                            image: AssetImage(
                              AppImages.icon_app_work_plan,
                            ),
                          ),
                        ),
                      ),
                    ),
                    Expanded(
                      child: Container(
                        color: const Color(0xffF5F5F6),
                        child: TabBarView(
                          children: [
                            PlanInfoPage(),
                            TrainCoursePage(),
                            GetBuilder(
                                init: controller,
                                builder: (_) {
                                  return ApprovalProcessWidget(nodeList: controller.processList);
                                })
                          ],
                        ),
                      ),
                    ),
                    SizedBox(height: 210.w),
                  ],
                ),
              ),
            ),
            bottomSheet: ApprovalBottomSheet(onOpinion: controller.onOpinion, onSign: controller.onSign, onOperation: controller.onOperation),
          )
        : Scaffold(
            appBar: CustomAppBar(
              titleText: '在线培训',
            ),
            body: Container(
              color: AppColors.bg_color_grey,
              child: DefaultTabController(
                length: 4,
                initialIndex: controller.initPage,
                child: Column(
                  children: [
                    Container(
                      decoration: BoxDecoration(
                        color: Colors.white,
                        borderRadius: BorderRadius.circular(8),
                      ),
                      height: 54.w,
                      child: TabBar(
                        enableFeedback: false,
                        tabs: const [
                          Tab(text: '计划信息'),
                          Tab(text: '培训课程'),
                          Tab(text: '培训结果'),
                          Tab(text: '审批流程'),
                        ],
                        isScrollable: true,
                        tabAlignment: TabAlignment.center,
                        dividerColor: Colors.transparent,
                        labelPadding: EdgeInsets.only(bottom: 10.w, left: 13.w, right: 13.w),
                        labelStyle: TextStyle(
                          fontSize: 16.sp,
                          fontWeight: FontWeight.w500,
                        ),
                        unselectedLabelStyle: TextStyle(
                          fontSize: 16.sp,
                          fontWeight: FontWeight.w500,
                        ),
                        labelColor: Colors.black,
                        unselectedLabelColor: const Color(0xffA0A7B5),
                        indicatorPadding: EdgeInsets.only(top: 36.w, bottom: 10.w),
                        indicator: const BoxDecoration(
                          image: DecorationImage(
                            image: AssetImage(
                              AppImages.icon_app_work_plan,
                            ),
                          ),
                        ),
                      ),
                    ),
                    Expanded(
                      child: Container(
                        color: const Color(0xffF5F5F6),
                        child: TabBarView(
                          children: [
                            PlanInfoPage(),
                            TrainCoursePage(),
                            TrainResultPage(),
                            GetBuilder(
                                init: controller,
                                builder: (_) {
                                  return ApprovalProcessWidget(nodeList: controller.processList);
                                })
                          ],
                        ),
                      ),
                    ),
                  ],
                ),
              ),
            ),
          );
  }
}
